package com.sumansoul.minamanageconnect;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import static com.sumansoul.minamanageconnect.BaseApplication.jWebSClient;
import static com.sumansoul.minamanageconnect.BaseApplication.jWebSClientService;

public class MainActivity extends Activity {
    
    private Button connectBtn;
    private Button disconnectBtn;
    private TextView messageTv;
    private EditText sendMsgEdit;
    private Button sendMsgBtn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        connectBtn = (Button)findViewById(R.id.connect_btn);
        disconnectBtn = (Button)findViewById(R.id.disconnect_btn);
        messageTv = (TextView)findViewById(R.id.message_tv);
        sendMsgEdit = (EditText)findViewById(R.id.send_msg_edit);
        sendMsgBtn = (Button)findViewById(R.id.send_msg_btn);

  

        connectBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               //http://49.234.188.68:7002/v1/app/ws/class/add/message
//                URI uri = URI.create("ws://49.234.188.68:7002/v1/app/ws/class/add/message");
//                JWebSocketClient client = new JWebSocketClient(uri) {
//                    @Override
//                    public void onMessage(String message) {
//                        //message就是接收到的消息
//                        Log.e("JWebSClientService", message);
//                    }
//                };


                if (jWebSClient != null && jWebSClient.isOpen()) {
                        jWebSClientService.sendMsg("封装测试消息111");
                    } else {
                        Toast.makeText(MainActivity.this,"连接已断开，请稍等或重启App哟",Toast.LENGTH_SHORT).show();
                    }

            }
        });
        

    }


}
